<?php
class ClientScript extends CClientScript
{
	/**
	 * @var str
	 */
	private $_fileVersion;

	/**
	 * @param string $filename
	 * @return string
	 */
	public function addFileVersion($filename)
	{
		if (null === $this->_fileVersion) {
			$versionFilename = Yii::getPathOfAlias('application.version');
			$this->_fileVersion = file_get_contents($versionFilename);
		}
		if (false === strpos($filename, '?')) {
			$filename .= '?v=' . $this->_fileVersion;
		}
		return $filename;
	}

	public function registerCssFile($url,$media='')
	{
		parent::registerCssFile($this->addFileVersion($url), $media);
	}

	public function registerScriptFile($url,$position=self::POS_HEAD)
	{
		parent::registerScriptFile($this->addFileVersion($url), $position);
	}


}